package cn.biz.imp;

import java.util.List;

import cn.biz.ConfigurationBiz;
import cn.dao.ConfigurationDao;
import cn.entity.Configuration;

public class ConfigurationBizImp implements ConfigurationBiz {
	private ConfigurationDao configurationDao;
	
	public ConfigurationDao getConfigurationDao() {
		return configurationDao;
	}

	public void setConfigurationDao(ConfigurationDao configurationDao) {
		this.configurationDao = configurationDao;
	}

	/*
	 * 添加一条Cart信息 成功返回一个success的字符串
	 * @see cn.biz.CartBiz#insert(cn.entity.Cart, java.lang.Integer, java.lang.Integer)
	 */
	@Override
	public String insertOrUpdate(Configuration config) {
		String result = "error";
		try {
			configurationDao.insertOrUpdate(config);
			result = "success";
		} catch (Exception e) {
			e.printStackTrace();
			result = "error";
		}
		return result;
	}

	/*
	 * 按照id删除一条Cart信息 成功返回一个success的字符串
	 * @see cn.biz.CartBiz#delete(java.lang.Integer)
	 */
	@Override
	public String delete(Integer id) {
		String result = "error";
		try {
			configurationDao.delete(id);
			result = "success";
		} catch (Exception e) {
			e.printStackTrace();
			result = "error";
		}
		return result;
	}

	/*
	 * 更新一条Cart信息 成功返回一个success的字符串
	 * @see cn.biz.CartBiz#update(cn.entity.Cart)
	 */
	@Override
	public String update(Configuration config) {
		String result="error";
		try {
			configurationDao.update(config);
			result="success";
		} catch (Exception e) {
			e.printStackTrace();
			result="error";
		}
		return result;
	}

	@Override
	public List query(Configuration config) {
		return configurationDao.query(config);
	}

	@Override
	public List getAll() {
		return configurationDao.getAll();
	}
	
	@Override
	public Configuration getConfigurationById(Integer id) {
		return configurationDao.getConfigurationById(id);
	}
	
	//根据状态编号获取状态
	public Configuration getStatusByStatusCode(String code){
		return configurationDao.getStatusByStatusCode(code);
	}

	//根据关键字类型获取全部关键字
	@Override
	public List<Configuration> getStatusByStatusType(String type) {
		return configurationDao.getStatusByStatusType(type);
	}
}
